package main

import "fmt"

func funcA() {
	fmt.Println("This is FUNCTION A")
}

func funcB() {
	defer func() {
		if msg := recover(); msg != nil {
			fmt.Println("FunB GETRecovered: ", msg)
		}
	}()
	fmt.Println("This is FuncB")
	for i := 0; i < 10; i++ {
		fmt.Println("i=", i)
		if i == 5 {
			panic("funcB ERROR")
		}
	}
}

func funcC() {
	defer func() {
		fmt.Println("执行函数延迟函数")
		msg := recover()
		fmt.Println("Func GET Recover: ", msg)
	}()
	fmt.Println("this is FuncC")
	panic("FuncC panic error")

}

func main() {
	funcA()
	funcB()
	funcC()
	fmt.Println("Main Over.")
}
